/**
 * elancom Corporation copy right 2012 - 2015  
 *   
 * $Header: https://192.168.1.224/svn/elancom/product/elancom-platform/trunk/src/main/java/com/elancom/framework/core/BeanRepository.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Id: BeanRepository.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Author: lanzhouxue $
 * $Date: 2012-07-02 11:09:12 +0800 (Mon, 02 Jul 2012) $
 * $Revision: 1034 $
 */
package com.elancom.framework;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContextAware;

/**
 * @author elancom
 * @date 2012-6-13
 */
public class BeanRepository implements ApplicationContextAware {
	private static org.springframework.context.ApplicationContext SPRING_APPLICATION_CONTEXT;

	@Override
	public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws BeansException {
		BeanRepository.SPRING_APPLICATION_CONTEXT = applicationContext;
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBean(String name) {
		return ((T) BeanRepository.SPRING_APPLICATION_CONTEXT.getBean(name));
	}
}
